<main>
    <?php
    if (!isset($_SESSION['IDupd'])) {
        include($root . "/teacher/pageParts/questionToggle.php");
    } else {
        $ID = $_SESSION['IDupd'];
        $sql = "SELECT * FROM questions WHERE questionID = '$ID'";
        $result = mysqli_query($db, $sql);
        $row = mysqli_fetch_assoc($result);

        $question = $row['questionDescription'];
        $correctPoints = $row['correctPoints'];
        $wrongPoints = $row['assHolePoints'];
        $answerA = $row['descriptionAnswerA'];
        $answerB = $row['descriptionAnswerB'];
        $answerC = $row['descriptionAnswerC'];
        $answerD = $row['descriptionAnswerD'];
        $answer = $row['answerABCD'];
    } ?>
    <div class="form">
        <form action="/teacher/logic/formLogic.php" method="POST">

            <label for="question">Question</label>
            <input type="text" id="question" name="question" placeholder="question text.." <?php if(isset($question)){echo "value = '$question'";}?> required>

            <label for="addPoints">Points for correct answer (0-10)</label>
            <input type="number" id="addPoints" name="addPoints" step="0.01" min="0" max="10" <?php if(isset($correctPoints)){echo "value = '$correctPoints'";}?> required><br>

            <label for="cutPoints">Minus points for wrong answer (0-10)</label>
            <input type="number" id="cutPoints" name="cutPoints" step="0.01" min="0" max="10" <?php if(isset($wrongPoints)){echo "value = '$wrongPoints'";}?> required><br><br>

            <input type="radio" name="answer" value="A" id="A" <?php if(isset($answer)){if($answer == 'A'){echo 'checked';}}else{echo 'checked';}?> />
            <label for="true">A</label>
            <input type="text" id="answerA" name="answerA" placeholder="answer text.." <?php if(isset($answerA)){echo "value = '$answerA'";}?> required>

            <input type="radio" name="answer" value="B" id="B" <?php if(isset($answer)){if($answer == 'B'){echo 'checked';}}?>/>
            <label for="true">B</label>
            <input type="text" id="answerB" name="answerB" placeholder="answer text.." <?php if(isset($answerB)){echo "value = '$answerB'";}?> required>

            <input type="radio" name="answer" value="C" id="C" <?php if(isset($answer)){if($answer == 'C'){echo 'checked';}}?>/>
            <label for="true">C</label>
            <input type="text" id="answerC" name="answerC" placeholder="answer text.." <?php if(isset($answerC)){echo "value = '$answerC'";}?> required>

            <input type="radio" name="answer" value="D" id="D" <?php if(isset($answer)){if($answer == 'D'){echo 'checked';}}?>/>
            <label for="true">D</label>
            <input type="text" id="answerD" name="answerD" placeholder="answer text.." <?php if(isset($answerD)){echo "value = '$answerD'";}?> required>

            <input type="submit" value="Submit">
        </form>
    </div>
</main>